package cn.edu.gsau.info.service.impl;

import cn.edu.gsau.info.dao.ShenHeDao;
import cn.edu.gsau.info.models.Shenhe;
import cn.edu.gsau.info.myenum.ModuleIdClass;
import cn.edu.gsau.info.service.IShenheService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


/**
 * @BelongsProject: gsau
 * @BelongsPackage: cn.edu.gsau.info.service.impl
 * @Author: kql
 * @CreateTime: 2022-11-28  10:39
 * @Description: TODO
 * @Version: 1.0
 */
@Service
public class ShenheServiceImpl extends ServiceImpl<ShenHeDao, Shenhe> implements IShenheService {
    @Autowired
    ShenHeDao shenheDao;
    /**
     * @Description 根据项目id获取审核流程
     * @Param [recoreId]
     * @return cn.edu.gsau.info.models.ShenHe;
     * @Date 2022/11/29 20:50
     * @Author qsy
     **/
    @Override
    public List<Shenhe> selectShenHe(long id){
        QueryWrapper qw=new QueryWrapper();
        qw.eq("moduleId", ModuleIdClass.ZHUANLIYURUANJIAN_id);
        qw.eq("recoreId",id);
        List<Shenhe> list=shenheDao.selectList(qw);
        return  list;
    }

    /**
     * @Description 添加审核流程
     * @Param [recoreId]
     * @return boolean
     * @Date 2022/11/29 15:50
     * @Author qsy
     **/

    @Override
    public boolean addShenHe(Shenhe shenHe){
        Date date=new Date();
        shenHe.setModuleId(ModuleIdClass.ZHUANLIYURUANJIAN_id);
        shenHe.setShenHeTime(date);
        int result=shenheDao.insert(shenHe);
        return result>0?true:false;
    }

    /**
     * @Description 根据项目id查询最后的审核记录
     * @Param [recoreId]
     * @return cn.edu.gsau.info.models.ShenHe;
     * @Date 2022/11/29 10:50
     * @Author qsy
     **/
    @Override
    public Shenhe findEndShenHe(long recoreId){
        Shenhe shenHe=shenheDao.findEndShenHe(recoreId);
        return shenHe;
    }
}
